import QtQuick 1.0

import Qt 4.7

Item {
    id: container

    width: 640; height: 50

    property alias text: textMessage.text
    property alias boxHeight: messageBox.height
    property alias boxWidth: messageBox.width

    signal clicked
    signal accept
    signal cancel

    states: [
        State {
            name: "normal"

            PropertyChanges {
                target: outFocus
                opacity: 0
            }

            PropertyChanges {
                target: focusHandler
                enabled: false
            }


            PropertyChanges {
                target: messageBox
                state: 'hide'
            }
        },

        State {
            name: "hideForeground"


            PropertyChanges {
                target: outFocus
                opacity: 0.5
            }

            PropertyChanges {
                target: focusHandler
                enabled: true
            }

            PropertyChanges {
                target: messageBox
                state: 'show'
            }

            PropertyChanges {
                target: okButton
                opacity: 1
            }
        }
    ]

    Rectangle {
        id: outFocus

        anchors.fill: parent
        color: 'black'
        opacity: 0

        Behavior on opacity { NumberAnimation{ duration: 600 } }

        MouseArea {
            id: focusHandler

            anchors.fill: parent
            enabled: true
        }


    }

    Rectangle {
        id: messageBox
        border {width: 3; color: "black"}
        radius: 5
        anchors.fill: parent

        Behavior on opacity { NumberAnimation { duration: 700 } }

        Text {
            id: textMessage
            text: "cxdcfdfd"
            anchors.centerIn: parent
            font { pointSize: 7; family: "Series 60 Sans"; weight: Font.Bold }
            horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter
        }


            TextButton {
                id: okButton
                x: 506
                y: 30
                width: 60
                height: 19
                text: "OK"
                colorGradientFrom: "#7e7373"
                anchors.right: parent.right
                anchors.rightMargin: cancelButton.width+15
                onClicked:
                {
                      //messageBox.visible = false;
                      console.log("ok buton clicked")
                      container.accept();
                }
            }
            TextButton {
            id: cancelButton
            x: 577
            y: 30
            width: 60
            height: 19
            text: "Cancel"
            colorGradientTo: "#f0f0f0"
            colorGradientFrom: "#7e7373"
            anchors.right: parent.right
            anchors.rightMargin: 5
            onClicked:
            {
                  //messageBox.visible = false;
                  console.log("cancel buton clicked")
                  container.cancel();
            }
        }



        states: [

            State {
                name: "hide"
                PropertyChanges {
                    target: messageBox;
                    opacity: 0
                }
            },

            State {
                name: "show"
                PropertyChanges {
                    target: messageBox
                    opacity: 1
                }
                PropertyChanges {
                    target: messageBox
                    focus: true
                }
            }
        ]
    }
}
